<template>
  <div class="question-practice-page">
     <BaseHeader
      :navs="navs"
      :activeNav="activeNav"
      @nav-change="activeNav = $event"
    />
     <nav :class="['nav', 'tabs',{ open: navOpen }]">
          <a href="#" :class="{ active: activeNavTi === 'CAAC' }" @click.prevent="activeNavTi = 'CAAC'">CAAC</a>
          <a href="#">AOPA</a>
          <a href="#">AGPA</a>
          <a href="#">UTC</a>
        </nav>
    <!-- 面包屑 -->
    <div class="breadcrumb">
      <span @click="$router.push('/')">首页</span> &gt; <span @click="$router.push('/questionBank')">题库</span> &gt; <span class="active">CAAC</span>
    </div>

    <!-- 主体内容 -->
    <div class="m-h-40">
      <div class="main-content">
        <div class="tab-bar">
          <span
            class="tab"
            :class="{ active: activeTab === 'practice' }"
            @click="activeTab = 'practice'"
          >
            章节练习 <span class="tab-badge">共11章</span>
          </span>
          <span
            class="tab"
            :class="{ active: activeTab === 'mock' }"
            @click="activeTab = 'mock'"
          >
            模拟试卷 <span class="tab-badge">共2套</span>
          </span>
        </div>
        <div class="table-wrapper">
          <table class="practice-table">
            <thead>
              <tr>
                <th class="ti_title" v-if="activeTab === 'practice'">章节练习</th>
                <th v-if="activeTab === 'mock'">试卷名称</th>
                <th>已做题数/总题数</th>
                <th>正确率</th>
                <th></th>
              </tr>
            </thead>
            <tbody>
              <tr
                v-for="(item, idx) in (activeTab === 'practice' ? practiceData : mockData)"
                :key="idx"
              >
                <td class="ti_title">{{ item.title }}</td>
                <td class="flex flex-col-center flex-center">
                  <div class="kuang">
                      <div class="success" :style="{'width':idx*10+'px'}"></div>
                  </div> 
                    0/10
              </td>
                <td>-</td>
                <td>
                  <button class="start-btn" @click="showDialog = true">{{idx>0?"继续做题":"开始做题"}}</button>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div v-if="showDialog" class="vip-dialog-mask">
      <div class="vip-dialog">
        <img src="@/assets/index/nomore.png" class="dialog-top-img" />
        <div class="dialog-msg">
          很抱歉您还未购买相应课程，无法查看相关资料哦！
        </div>
        <div class="dialog-btns">
          <button class="btn-cancel" @click="showDialog = false">取 消</button>
          <button class="btn-buy" @click="goBuy">去购买</button>
        </div>
      </div>
    </div>
    <!-- 底部信息 -->
  <BaseFooter />
  </div>
</template>

<script>
import BaseHeader from "@/components/baseHeader.vue";
import BaseFooter from "@/components/baseFooter.vue";
export default {
  name: "QuestionPractice",
  components: { BaseHeader, BaseFooter },
  data() {
    return {
      showDialog:false,
      navs: ["首页", "新闻", "题库", "资料", "产教课程"],
      activeNav: "题库",
      navOpen: false,
      activeNavTi: "CAAC",
      activeTab: "practice",
      practiceData: [
        { title: "第1章 项目管理基础" },
        { title: "第2章 项目运行环境" },
        { title: "第3章 人-项目管理与团队" },
        { title: "第4章 人-干系人与沟通" },
        { title: "第5章 过程-风险与整合" },
        { title: "第6章 过程-范围与需求" },
        { title: "第7章 过程-进度与成本" },
        { title: "第8章 过程-质量与采购" },
        { title: "第9章 过程-风险与不确定性" },
        { title: "第10章 过程-风险与不确定性" },
        { title: "第11章 敏捷宣言和常见团队三大角色" },
      ],
      mockData: [
        { title: "模拟试卷一" },
        { title: "模拟试卷二" },
      ],
    };
  },
  mounted() {
    window.addEventListener("resize", this.handleResize);
    this.handleResize();
  },
  beforeDestroy() {
    window.removeEventListener("resize", this.handleResize);
  },
  methods: {
    handleResize() {
      if (window.innerWidth > 900) {
        this.navOpen = false;
      }
    },
     goBuy() {
      // 跳转购买页面逻辑
      this.showDialog = false;
      // 例如：this.$router.push('/buy');
    },
  },
};
</script>

<style scoped>
.question-practice-page {
  background: #fafbff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
	overflow-x: hidden;
}
.header {
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  height: 60px;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 10;
}
.header-content {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  height: 60px;
  position: relative;
}
.logo {
  font-weight: bold;
  font-size: 18px;
  margin-right: 40px;
  white-space: nowrap;
}
.nav {
  display: flex;
  gap: 24px;
  transition: all 0.3s;
}
.nav a {
  color: #222;
  text-decoration: none;
  font-size: 15px;
  padding: 0 6px;
  line-height: 60px;
  transition: color 0.2s;
  border-bottom: 2px solid transparent;
}
.nav a.active,
.nav a:hover {
  color: #1664ff;
  font-weight: bold;
  border-bottom: 2px solid #1664ff;
}
.tabs{
    width:100vw;
    text-align:center;
    display: flex;
    justify-content: center;
    background:#fff;
    a{
        width:10%;
    }
}
.login-btn {
  background: #1664ff;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 28px;
  font-size: 15px;
  cursor: pointer;
  margin-left: 24px;
  white-space: nowrap;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  margin-left: 16px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 40px;
  width: 40px;
}
.bar {
  display: block;
  width: 24px;
  height: 3px;
  background: #1664ff;
  margin: 4px 0;
  border-radius: 2px;
  transition: all 0.3s;
}
@media (max-width: 900px) {
  .header-content {
    padding: 0 12px;
  }
  .nav {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: #fff;
    flex-direction: column;
    gap: 0;
    box-shadow: 0 2px 8px #e6eaf5;
    display: none;
    z-index: 100;
  }
  .nav.open {
    display: flex;
  }
  .nav a {
    line-height: 48px;
    padding: 0 24px;
    border-bottom: 1px solid #f0f0f0;
  }
  .login-btn {
    padding: 8px 16px;
    font-size: 15px;
    margin-left: 8px;
  }
  .nav-toggle {
    display: flex;
  }
}
.breadcrumb {
  max-width: 1200px;
  min-width:1000px;
  color: #888;
  font-size: 14px;
  text-align:left;
  margin:30px auto 10px;
  cursor:pointer;
}
.main-content {
  max-width: 1200px;
  min-width:1000px;
  margin: 24px auto 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px #e6eaf5;
  padding: 32px 0 40px 0;
  margin-bottom:40px;
}
.tab-bar {
  display: flex;
  gap: 32px;
  margin-left: 32px;
  margin-bottom: 18px;
}
.tab {
  font-size: 18px;
  color: #222;
  cursor: pointer;
  position: relative;
  padding-bottom: 4px;
}
.active{
    color: #1664ff;
}
.tab.active {
  color: #1664ff;
  font-weight: bold;
  border-bottom: 2px solid #1664ff;
}
.tab-badge {
  background: #e6f0ff;
  color: #1664ff;
  font-size: 12px;
  border-radius: 8px;
  padding: 2px 8px;
  margin-left: 8px;
}
.table-wrapper {
  padding: 0 32px;
}
.practice-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #ebeef5;
  border-radius: 12px;
  overflow: hidden;
}
.practice-table th {
  background: #f7faff;
  color: #222;
  padding: 14px 0;
  text-align: center;
  font-weight: 500;
  font-size: 15px;
  border: 1px solid #ebeef5;
}
.practice-table td {
  padding: 14px 0;
  border: 1px solid #ebeef5;
  color: #606266;
  font-size: 15px;
  text-align: center;
}
.start-btn {
  background: #fff;
  color: #1664ff;
  border: 1px solid #1664ff;
  border-radius: 4px;
  padding: 6px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.start-btn:hover {
  background: #1664ff;
  color: #fff;
}
.footer {
  background: #4d7cff;
  color: #fff;
  margin-top: auto;
  padding-top: 36px;
}
.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 48px;
  padding-bottom: 24px;
  flex-wrap: wrap;
}
.footer-col {
  flex: 1;
  min-width: 120px;
}
.footer-title {
  font-weight: bold;
  margin-bottom: 12px;
  font-size: 16px;
}
.footer-link {
  margin-bottom: 8px;
  font-size: 14px;
}
.footer-btn {
  margin-top: 10px;
  background: #fff;
  color: #1664ff;
  border: none;
  border-radius: 4px;
  padding: 6px 18px;
  font-size: 14px;
  cursor: pointer;
}
.qr-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}
.qr-placeholder {
  width: 80px;
  height: 80px;
  background: #eaeaea;
  border-radius: 8px;
  margin-bottom: 8px;
}
.footer-bottom {
  text-align: center;
  font-size: 13px;
  color: #e0e6ff;
  padding: 16px 0 8px 0;
  border-top: 1px solid #6e8fff;
  background: #4d7cff;
}
.practice-table .ti_title{
    text-align:left
}
.vip-dialog-mask {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vip-dialog {
  width: 480px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
  padding: 40px 32px 32px 32px;
  text-align: center;
  position: relative;
}
.dialog-top-img {
  width: 120px;
  margin-bottom: 16px;
  margin-top: -40px;
}
.dialog-msg {
  font-size: 20px;
  color: #222;
  font-weight: 600;
  margin-bottom: 36px;
  margin-top: 8px;
}
.dialog-btns {
  display: flex;
  justify-content: center;
  gap: 24px;
  .btn-cancel {
    width: 120px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid #e5e6eb;
    background: #fff;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    transition: border 0.2s;
    &:hover {
      border: 1px solid #1664ff;
    }
  }
  .btn-buy {
    width: 120px;
    height: 44px;
    border-radius: 8px;
    border: none;
    background: #1664ff;
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    &:hover {
      background: #0056d6;
    }
  }
}
.flex{
    display: flex;

} 
.flex-center{
   justify-content:center
}
.flex-col-center{
    align-items: center;
}
.kuang{
    width:100px;
    height:8px;
    background:#f7faff;
    border-radius:5px;
    margin-right:5px;
    position:relative;
    .success{
        position:absolute;
        left:0;
        background:#1664ff;
        height:8px;
        border-radius:5px;
    }
}
.m-h-40{
  min-height:50vh;
  max-width: 1200px;
  min-width: 1000px;
  margin: 0 auto;
}
</style>